#include <iostream>
using namespace std;

int main()
{
	int n,x;
	int geWei;
	int count = 0;
	int temp = 0;
	cin >> n >> x;
	for(int i = 1;i <= n;i++){
		temp = i;
		while(temp != 0){
			geWei = temp % 10;
			if(geWei == x){
				count = count + 1;
			}
			temp = temp / 10;
		}
	}
	
	cout << count << endl;
	
	return 0;
}
